package com.gangye.service.impl;

import com.gangye.entity.User;
import com.gangye.mapper.mapper1.UserMapper;
import com.gangye.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Classname UserServiceImpl
 * @Description userSercice的接口实现类
 * @Date 2020/5/27 9:49
 * @Created by gangye
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User getUserByPrimarykey(Integer id) {
        return userMapper.findById(id);
    }

    @Override
    public List<User> showAllUsers() {
        return userMapper.showAll();
    }

    @Override
    @Transactional(transactionManager = "primaryTransactionManager")
    public void insertOneUser(User user) {
        userMapper.insert(user);
    }

    @Override
    @Transactional(transactionManager = "primaryTransactionManager")
    public void updateUserInfo(User user) {
        userMapper.update(user);
    }
}
